﻿var ColorHex = new Array('00', '33', '66', '99', 'CC', 'FF')
var SpColorHex = new Array('FF0000', '00FF00', '0000FF', 'FFFF00', '00FFFF', 'FF00FF')
var current = null
var targetElement = null; //接收颜色对话框返回值的元素
var colorpaneldivid = null;
function intocolor(colorpanelid, parentEle, clickcodeName) {
    colorpaneldivid = colorpanelid;
    var colorTable = ''
    for (i = 0; i < 2; i++) {
        for (j = 0; j < 6; j++) {
            colorTable = colorTable + '<tr height=12>'
            colorTable = colorTable + '<td width=11 onmouseover="doOver(this)" onmouseout="doOut(this)" onclick="' + clickcodeName + '(this)" style="background-color:#000000"></td>'

            if (i == 0) {
                colorTable = colorTable + '<td width=11 onmouseover="doOver(this)" onmouseout="doOut(this)" onclick="' + clickcodeName + '(this)" style="background-color:#' + ColorHex[j] + ColorHex[j] + ColorHex[j] + '"></td>'
            }
            else {
                colorTable = colorTable + '<td width=11 onmouseover="doOver(this)" onmouseout="doOut(this)" onclick="' + clickcodeName + '(this)" style="background-color:#' + SpColorHex[j] + '"></td>'
            }


            colorTable = colorTable + '<td width=11 onmouseover="doOver(this)" onmouseout="doOut(this)" onclick="' + clickcodeName + '(this)" style="background-color:#000000"></td>'
            for (k = 0; k < 3; k++) {
                for (l = 0; l < 6; l++) {
                    colorTable = colorTable + '<td width=11 onmouseover="doOver(this)" onmouseout="doOut(this)" onclick="' + clickcodeName + '(this)" style="background-color:#' + ColorHex[k + i * 3] + ColorHex[l] + ColorHex[j] + '"></td>'
                }
            }
            colorTable += "</tr>";
        }
    }
    colorTable = '<table width=253 border="0" cellspacing="0" cellpadding="0" style="border:1px #000000 solid;border-bottom:none;border-collapse: collapse" bordercolor="000000">'
           + '<tr height=30><td colspan=21 bgcolor=#cccccc>'
           + '<table cellpadding="0" cellspacing="1" border="0" style="border-collapse: collapse">'
           + '<tr><td width="3"><td><input type="text" id="DisColor" size="6" disabled style="border:solid 1px #000000;background-color:#ffff00"></td>'
           + '<td width="3"><td><input type="text" id="HexColor" size="7" style="border:inset 1px;font-family:Arial;" value="#000000"></td></tr></table></td></table>'
           + '<table border="1" cellspacing="0" cellpadding="0" style="border-collapse: collapse" bordercolor="000000"  style="cursor:hand;">'
           + colorTable + '</table>';
    var colorPaneldiv = document.createElement('div');
    colorPaneldiv.id = colorpaneldivid;
    colorPaneldiv.className = "colorset";
    colorPaneldiv.innerHTML = colorTable;
    colorPaneldiv.style.display = "none";          
    colorPaneldiv .style.width="253px";
    colorPaneldiv .style.height="177px";
    parentEle.appendChild(colorPaneldiv);
}

//此函数已被千一网络修改 www.cftea.com
//将颜色值字母大写
function doOver(thisObj) {
    thisObj = thisObj || window.event;
    var srcEle = thisObj;
    if ((srcEle.tagName == "TD") && (current != srcEle)) {
        if (current != null) { current.style.backgroundColor = current._background }
        srcEle._background = srcEle.style.backgroundColor
        document.getElementById ('DisColor').style.backgroundColor = srcEle.style.backgroundColor
        document.getElementById('HexColor').value = srcEle.style.backgroundColor.toUpperCase();
        srcEle.style.backgroundColor = "white"
        current = srcEle;
    }
}

//此函数已被千一网络修改 www.cftea.com
//将颜色值字母大写
function doOut(thisObj) { 
    if (current != null) current.style.backgroundColor = current._background.toUpperCase();
}

//此函数已被千一网络修改 www.cftea.com
function doclick(thisObj) {
    if (event.srcElement.tagName == "TD") {
        var clr = event.srcElement._background;
        clr = clr.toUpperCase(); //将颜色值大写
        if (targetElement) {
            //给目标无件设置颜色值
            targetElement.value = clr;
        }alert(clr);
        return clr;
    }
}

var smileArray = [[0, "微笑"], [1, "撇嘴"], [2, "色"], [3, "发呆"], [4, "得意"], [5, "流泪"], [6, "害羞"], [7, "闭嘴"], [8, "睡"], [9, "大哭"],
                [10, "尴尬"], [11, "发怒"], [12, "调皮"], [13, "呲牙"], [14, "惊讶"], [15, "难过"], [16, "冷汗"], [17, "酷"], [18, "抓狂"], [19, "吐"],
                [20, "偷笑"], [21, "可爱"], [22, "白眼"], [23, "傲慢"], [24, "饥饿"], [25, "困"], [26, "惊恐"], [27, "流汗"], [28, "憨笑"], [29, "大兵"],
                [30, "奋斗"], [31, "咒骂"], [32, "疑问"], [33, "嘘"], [34, "晕"], [35, "衰"], [36, "骷髅"], [37, "敲打"], [38, "再见"], [39, "擦汗"],
                [40, "扣鼻"], [41, "鼓掌"], [42, "丑大了"], [43, "坏笑"], [44, "折磨"], [45, "左哼哼"], [46, "右哼哼"], [47, "哈欠"], [48, "鄙视"], [49, "委屈"],
                [50, "快哭了"], [51, "阴险"], [52, "亲亲"], [53, "吓"], [54, "可怜"], [55, "菜刀"], [56, "西瓜"], [57, "啤酒"], [58, "篮球"], [59, "乒乓"],
                [60, "咖啡"], [61, "米饭"], [62, "猪头"], [63, "玫瑰"], [64, "凋谢"], [65, "示爱"], [66, "爱心"], [67, "心碎"], [68, "蛋糕"], [69, "闪电"],
                [70, "炸弹"], [71, "刀"], [72, "足球"], [73, "瓢虫"], [74, "便便"], [75, "月亮"], [76, "太阳"], [77, "礼物"], [78, "抱抱"], [79, "强"],
                [80, "弱"], [81, "握手"], [82, "胜利"], [83, "抱拳"], [84, "勾引"], [85, "拳头"], [86, "差劲"], [87, "爱你"], [88, "NO"], [89, "OK"],
                [90, "爱情"], [91, "飞吻"], [92, "跳跳"], [93, "发抖"], [94, "怄火"], [95, "转圈"], [96, "磕头"], [97, "回头"], [98, "跳绳"], [99, "挥手"],
                [100, "激动"], [101, "街舞"], [102, "献吻"], [103, "左太极"], [104, "右太极"]];
function initSmile(smileid,parentEle,clickCodeName) {
    var index = 0;
    var imgsrc = "";
    var smileTable = "<table>";
    for (var i = 0; i <= 104; i++) {
        if (i < 7)
            imgsrc = "img/qsmile/" + (i+1).toString()+".gif";
        else
            imgsrc = "img/qsmile/" + (i+1).toString() + ".gif";
        if (i % 15 == 0) {
            smileTable +="<tr>"
        }
        smileTable += '<td style="border:solid 1px #FFF" onmouseover="imgMouseOver(this)" onmouseout="imgMouseOut(this)"><img title="' + smileArray[i][1] + '" onclick="' + clickCodeName + '(this);" src="' + imgsrc + '" ;"/></td>';
        if (i % 15 == 14) {
            smileTable += "</tr>";
        }
    }
    smileTable += "</table>";
    var newSmileDiv = document.createElement("div");
    newSmileDiv.id = smileid;
    newSmileDiv.className = "smileset";
    newSmileDiv.style.position = "absolute";
    newSmileDiv.style.display = "none";
    newSmileDiv.style.width="500px";
    newSmileDiv.style.height="242px";
    newSmileDiv.innerHTML = smileTable;      
    parentEle.appendChild(newSmileDiv);
}

function imgMouseOver(thisObj) {
    thisObj.style.border = "solid 1px lightBlue";
    thisObj.style['background-color'] = "blue";
}
function imgMouseOut(thisObj){
    thisObj.style.border = "solid 1px #FFF";
    thisObj.style['background-color'] = "";
}

function getTop(e) {
    var offset = e.offsetTop;
    if (e.offsetParent != null) {
        if (e.offsetParent.style.position == "absolute") {
            if (Sys.firefox)
                offset += parseInt(e.offsetParent.style.top);
            return offset;
        }
        offset += getTop(e.offsetParent);
    }
    return offset;
}
function getLeft(e) {
    var offset = e.offsetLeft;
    if (e.offsetParent != null) {
        if (e.offsetParent.style.position == "absolute") {
            if (Sys.firefox)
                offset += parseInt(e.offsetParent.style.left);
            return offset;
        }
        offset += getLeft(e.offsetParent);
    }
    return offset;
}    